package com.sunny.t2;

import java.util.Scanner;

public class Main {

    static final int MAXN = 500005;

    static Point[] points = new Point[MAXN];

    static boolean[] used = new boolean[MAXN];

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();

        for(int i=0;i<n;i++){
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            int c = scanner.nextInt();
            points[i] = new Point(a,b,c);
        }
//        for(int i=0;i<n;i++)
//            System.out.println(points[i].x+" "+points[i].y+" "+points[i].z);

        int res = 0;
        for(int i=0;i<n;i++){
            if(used[i]) {
                continue;
            }
            int j = i+1;
            for(;j<n;j++){
                if(used[j] || i==j)
                    continue;
                int tag = judge(points[i], points[j]);
                if(tag == 0)
                    continue;
                res++;
                if(tag == 1){
                    used[i] = true;
                    break;
                }else if(tag == -1){
                    used[j] = true;
                }
            }
        }

        System.out.println(res);

    }

    public static int judge(Point a, Point b){
        if(a.x<b.x && a.y<b.y && a.z<b.z){
            return 1;
        }else if(a.x>b.x && a.y>b.y && a.z>b.z){
            return -1;
        }
        return 0;
    }

}


class Point{
    int x,y,z;

    public Point(int x, int y, int z) {
        this.x = x;
        this.y = y;
        this.z = z;
    }
}